/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bean.lazy;

import org.ipti.br.tag.dao.HumanFacade;
import org.ipti.br.tag.entity.Human;
import java.util.List;
import java.util.Map;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;

/**
 *
 * @author israel
 */
public class LazyHumanWithActorsDataModel extends LazyDataModel<Human>{
    private HumanFacade humanDAO;
    
    private List<Long> unities;
    
    private Long personageID;

    public LazyHumanWithActorsDataModel(HumanFacade humanDAO, List<Long> unities, Long personageID) {
        this.humanDAO = humanDAO;
        this.unities = unities;
        this.personageID = personageID;
    }
    
    @Override
    public List<Human> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
        return humanDAO.searchHumanWithActorActivatedPerPersonageUnities(unities, personageID, first, pageSize, filters);
    }

    @Override
    public int getRowCount() {
        return humanDAO.getHumanWithActorActivatedPerPersonageUnitiesCount(unities, personageID);
    }

    public HumanFacade getHumanDAO() {
        return humanDAO;
    }

    public void setHumanDAO(HumanFacade humanDAO) {
        this.humanDAO = humanDAO;
    }

    public Long getPersonageID() {
        return personageID;
    }

    public void setPersonageID(Long personageID) {
        this.personageID = personageID;
    }

    public List<Long> getUnities() {
        return unities;
    }

    public void setUnities(List<Long> unities) {
        this.unities = unities;
    }    
    
}
